package cn.virens.common.mapper.example;

import cn.virens.common.exception.APIException;
import cn.virens.common.mapper.example.base.AbstractExampleCriteriaCriterion;
import cn.virens.common.mapper.example.util.Util;

@SuppressWarnings("serial")
public class ExampleCriteria extends AbstractExampleCriteriaCriterion<ExampleCriteria> {

    public ExampleCriteria(String andOr, String condition, Object value1, Object value2) {
        super(andOr, condition, value1, value2);
    }

    public ExampleCriteria(String andOr, String condition, Object value1) {
        super(andOr, condition, value1);
    }

    public ExampleCriteria(String andOr, String condition) {
        super(andOr, condition);
    }

    public ExampleCriteria(String andOr) {
        this(andOr, null);
    }

    protected ExampleCriteria addCriterion(String andOr, String condition) throws APIException {
        this.criterionList.add(new ExampleCriteria(andOr, condition));

        return this;
    }

    protected ExampleCriteria addCriterion(String andOr, String condition, Object value) throws APIException {
        if (condition != null && !condition.isEmpty() && value != null && Util.isNotEmpty(value)) {
            this.criterionList.add(new ExampleCriteria(andOr, condition, enumv(value)));
        }

        return this;
    }

    protected ExampleCriteria addCriterion(String andOr, String condition, Object value1, Object value2) throws APIException {
        this.criterionList.add(new ExampleCriteria(andOr, condition, value1, value2));

        return this;
    }

}
